package com.example.tourapp.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.tourapp.Pojo.Pojo_telephone;
import com.example.tourapp.R;

import java.util.List;

public class Telephone_Apadter extends BaseAdapter {
    private List<Pojo_telephone> list;
    private Context context;

    public Telephone_Apadter(List<Pojo_telephone> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null)
        {
            view= LayoutInflater.from(context).inflate(R.layout.mode_telephone,viewGroup,false);
            holder=new ViewHolder();
             holder.t_number= view.findViewById(R.id.t_number);
             holder.t_name=view.findViewById(R.id.t_name);
             view.setTag(holder);
        }else
        {
            holder = (ViewHolder) view.getTag();
        }

        holder.t_number.setText(list.get(i).getT_number());
        holder.t_name.setText(list.get(i).getT_name());

        return view;
    }

    class ViewHolder{
        TextView t_name;
        TextView t_number;
    }
}
